import {
  listParams,
  ListItemGetResultModel,
  ICreatingDatabaseData,
  IAddOrUpdateOrgData,
  ITestDBData,
  IOrgDataSourceInfoVoResData,
  IPaymenConfigUpdateData,
  IBrokerageConfigListResData,
  IOrgPermissionResData,
} from './model/listModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  list = '/admin/org-basics-config/pageList',
  creatingDatabase = '/admin/org/Data/source/creatingDatabase',
  addOrUpdateOrg = '/admin/org-basics-config/addOrUpdateOrg',
  configDetails = '/admin/org-basics-config/getConfigDetails/',
  testDB = '/admin/org/Data/source/testDB',
  orgDataSourceInfoVo = '/admin/org/Data/source/getOrgDataSourceInfoVo/',

  paymenConfig = '/admin/org-paymenconfig/op/get',
  paymenConfigUpdate = '/admin/org-paymenconfig/op/update',

  brokerageConfigList = '/admin/brokerageConfig/findByOrgId/',
  brokerageConfigSave = '/admin/brokerageConfig/save',

  orgPermissionData = '/admin/orgPermission/findByOrgId/',
  orgPermissionSave = '/admin/orgPermission/save',
  getQrcode = '/admin/org-basics-config/getQrcode'
}

/**
 * @description 机构列表
 * @date 13/07/2022
 * @export
 * @param {institutionListParams} params
 */
export function list(params: listParams) {
  return defHttp.get<ListItemGetResultModel>({
    url: Api.list,
    params,
  });
}

/**
 * @description 获取二维码
 * @date 13/07/2022
 * @export
 * @param {id} params
 */
export function getQrcode(id: number) {
  return defHttp.get({
    url: Api.getQrcode + '/' + id,
  });
}

/**
 * @description 新增、修改机构
 * @date 07/11/2022
 * @export
 * @param {IAddOrUpdateOrgData} data
 */
export function addOrUpdateOrg(data: IAddOrUpdateOrgData) {
  return defHttp.post({
    url: Api.addOrUpdateOrg,
    data,
  });
}

/**
 * @description 机构详情
 * @date 07/11/2022
 * @export
 * @param
 */
export function configDetails(id: number) {
  return defHttp.get<IAddOrUpdateOrgData>({
    url: Api.configDetails + id,
  });
}

/**
 * @description 生成SAAS部署数据
 * @date 04/11/2022
 * @export
 * @param {ICreatingDatabaseData} data
 */
export function creatingDatabase(data: ICreatingDatabaseData) {
  return defHttp.post({
    url: Api.creatingDatabase,
    data,
  });
}

/**
 * @description 测试数据链接
 * @date 04/11/2022
 * @export
 * @param {ITestDBData} data
 */
export function testDB(data: ITestDBData) {
  return defHttp.post({
    url: Api.testDB,
    data,
  });
}

/**
 * @description 根据机构id获取数据详情
 * @date 04/11/2022
 * @export
 * @param {number} id
 */
export function orgDataSourceInfoVo(id: string | number) {
  return defHttp.get<IOrgDataSourceInfoVoResData>({
    url: Api.orgDataSourceInfoVo + id,
  });
}

/**
 * @description 根据机构id获取支付配置详情
 * @date
 * @export
 * @param {number} id
 */
export function PaymenConfig(id: string | number) {
  return defHttp.get({
    url: Api.paymenConfig + `/${id}`,
  });
}

/**
 * @description 修改支付配置
 * @date
 * @export
 * @param
 */
export function PaymenConfigUpdate(data: IPaymenConfigUpdateData) {
  return defHttp.post({
    url: Api.paymenConfigUpdate,
    data,
  });
}

/**
 * @description 分润设置列表
 * @date 13/07/2022
 * @export
 * @param {id} params
 */
export function BrokerageConfigList(id: number) {
  return defHttp.get<IBrokerageConfigListResData>({
    url: Api.brokerageConfigList + id,
  });
}

/**
 * @description 分润设置保存
 * @date 13/07/2022
 * @export
 * @param {data} params
 */
export function BrokerageConfigSave(data: any) {
  return defHttp.post({
    url: Api.brokerageConfigSave,
    data,
  });
}

/**
 * @description 权限设置数据
 * @date 13/07/2022
 * @export
 * @param {id} params
 */
export function OrgPermissionData(id: string | number) {
  return defHttp.get<IOrgPermissionResData>({
    url: Api.orgPermissionData + id,
  });
}

/**
 * @description 权限设置数据保存
 * @date 13/07/2022
 * @export
 * @param {data} params
 */
export function OrgPermissionSave(data: any) {
  return defHttp.post({
    url: Api.orgPermissionSave,
    data,
  });
}
